﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PhotoResizer
{
    public partial class CheckUpdate : Form
    {
        public CheckUpdate()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            this.Cursor = Cursors.WaitCursor;

            PRWebService.Service a = new PRWebService.Service();

            string currVersion = a.VersionCheck();
            string thisVersion = label3.Text;
            if (String.Compare(currVersion, thisVersion) == 0)
            {   //same
                MessageBox.Show("This is the latest version. No need to update at this time :)", "Update Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Hide();
            }
            else
            {//old or different
                DialogResult result = MessageBox.Show("The latest version is "+currVersion +" . Would you like to update?", "Update Result", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

                if (result == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("http://photoresizer.bhavikvora.com");
                    this.Hide();
                }
                else
                {
                    //cancelled
                    this.Hide();
                }
            }

            this.Cursor = Cursors.Default;
            button1.Enabled = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
        }
    }
}
